<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<style>
    <!--
    -->
    .form-group > label {
        width: 60px;
    }
</style>
<script type="text/javascript">
    var role = {
        showGridData: function (list, domainNo) {
            var list = list;
            var trs = "";
            var operation = "";

            var tempCount = '<tr><td>{tp0}</td><td>{tp1}</td><td>{tp2}</td><td>{tp3}</td><td>{tp4}</td></tr>';

            for (var i = 0; list != null && i < list.length; i++) {
                var edit = '&nbsp;<a class="btn btn-blue" data-icon="edit" data-id="cpi"	data-title="编辑角色信息" data-height="300" data-width="450" data-mask="true" data-toggle="dialog" href="role/updatePage.shtml?id=' + list[i].id + '">编辑</a>';
                var quit = '&nbsp;<a	class="btn btn-red" data-icon="minus"  data-toggle="doajax" data-confirm-msg="请确认是否删除当前角色？" data-callback="doAjaxCallBackForNotForm"  href="role/delete.shtml?id=' + list[i].id + '">删除</a>';
                var arrange = '&nbsp;<a	class="btn btn-blue" data-icon="edit" data-height="500" data-width="400" data-mask="true" data-toggle="dialog" data-callback="doAjaxCallBack"  href="role/roleMenuPage.shtml?id=' + list[i].id + '">角色菜单权限变更</a>';
                //O是管理员权限拥有所有操作
                if (domainNo != 'O') {
                    edit = "无";
                    quit = "";
                    arrange = "";
                }
                operation = edit + quit + arrange;

                var tempStr = tempCount
                    .replace("{tp0}", (i + 1))
                    .replace("{tp1}", list[i].name)
                    .replace("{tp2}", list[i].type)
                    .replace("{tp3}", list[i].remark)
                    .replace("{tp4}", operation)

                trs += tempStr;

                $.CurrentNavtab.find("#rolelist").html("");
                $.CurrentNavtab.find("#rolelist").append(trs);

            }
            $.CurrentNavtab.find("th").css("text-align", "center");
            $.CurrentNavtab.find("td").css("text-align", "center");
        }
    };

    $(function () {
        var roleList = ${roleList};
        role.showGridData(roleList, 'O');

    });

</script>
<div class="bjui-pageHeader"
     style="height: auto; padding-top: 10px; padding-bottom: 10px;">
    <div class="col-md-4">
        <div class="form-group " align="center">
            <a class="btn btn-blue" data-icon="plus" data-id="addRole"
               data-title="新增角色" data-height="280" data-width="450"
               data-mask="true" data-toggle="dialog"
               href="role/addPage.shtml">新增角色</a>
        </div>
    </div>
</div>
<div class="bjui-pageContent">
    <div class="bjui-pageContent tableContent" id="contentList">
        <table data-toggle="tablefixed" data-width="100%" data-nowrap="true" id="roletable">
            <thead>
            <tr id="usertr">
                <th width="40">序号 <br></th>
                <th width="120">角色名称<br></th>
                <th width="120">角色类型<br></th>
                <th width="120">备注<br></th>
                <th width="200">操作<br></th>
            </tr>
            </thead>
            <tbody id="rolelist">
            </tbody>
        </table>
    </div>
    </div>
</div>
